package utils

import (
	"os"
	"os/signal"
	"syscall"
	"time"
)

func HandleInterrupts(f func()) {
	notifier := make(chan os.Signal, 1)
	signal.Notify(notifier, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
	<-notifier
	f()
}

func HandleTimeOut(second int, f func()) {
	select {
	case <-time.After(time.Second * time.Duration(second)):
		f()
	}
}
